/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef PAGES_H
#define PAGES_H

#include <QWidget>
#include <QtGui>
#include "clickedLabel.h"

#include "qcustomplot/qcustomplot.h"

class TestPage : public QWidget
{
    Q_OBJECT

public:
    TestPage(QWidget *parent = 0);
public:
    typedef struct _ETC_Send
    {
        char    de_name[6];
        char	sf;    /*算法选择  0表示工程算法，1表示理论算法, ! 表示复位 # 表示延时时间测量 */
        char	tbfs;  /*同步方式  0,同步输出；1,电秒脉冲；2,光秒脉冲3,B码电信号；4,B码光信号；5,50Hz倍频*/
        char	bzxz;  /*标准选择  0,5A；1,1A；2,100V；3,100/√3V；4,模拟小电压；5,谐波小电压*/
        float	xdyz;  /*小电压值  如果标准选择为4或者5，则有数，否则用0填充*/
        char    bcxz;  /*被测选择  0,5A；1,1A；2,100V；3,100/√3V；4,模拟小电压；5,9-1/2；6，FT3*/
        float   ydyz;   /*多样值    如果被测选择为0~3,则全部填充为0;如果为4,则用float类型填充;如果为5或者6,则填写通道号;*/
        char    ft3_tdh;    /*ft3通道号*/
        char	xbNum; /*谐波次数*/
        float   xbValue; /*谐波有效值*/
        char    netport[4];    /*输入端口*/
        char    ex[20];
    }ETC_Send;

    typedef struct _MUT_Send
    {
        char    de_name[6];
        char	udp_type;   /* 与_ETC_Send兼容，避开0x30,0x31,'!','#','*'. 使用'a','b','c'等 */
        char	tbfs;       /*同步方式  0,同步输出；1,电秒脉冲；2,光秒脉冲3,B码电信号；4,B码光信号；5,50Hz倍频；非同步*/
        char	ycdy;       /*一次电压  0-100，1-100√V */
        char    ycdl;       /*一次电流  0-1A, 1-5A     */
//        float	xdyz;       /*小电压值  如果标准选择为4或者5，则有数，否则用0填充*/
        char    bcxz;       /*被测选择  0-9-2, 1-FT3*/
        char    tdlb[6];    /*通道列表 9-2时不使用，FT3时按Ua，Ub，Uc，Ia，Ib，Ic顺序给出通道号*/
        char    ex[20];
    }MUT_Send;

public:
    void getsendUdp(char* ch,int flag);
    int getStructLen();

    void getsendUdp_mut(char * ch,int flag);
    int getUdpMutLen() {return sizeof(MUT_Send);}
public:
    QLabel *labDw;
    QLabel *labFz3;
    QLabel *labFz2;
    QLabel *labFz1;
    QLabel *labFz0;
    QLabel *labFz1a;
    QLabel *labFz2a;
    QLabel *labFz3a;
    QWidget *widget;
    QLabel *labFuzhi;
    QLabel *labFuzhiValue;

    QLineEdit *txtBzYxz;
    QLineEdit *txtBcYxz;
    QLineEdit *txtBc;
    QLineEdit *txtBzXw;
    QLineEdit *txtBcXw;
    QLineEdit *txtBzz;
    QLineEdit *txtBcz;
    QLineEdit *txtJc;

    QLineEdit *txtBFB;
    QLabel *labInfo;
    QLabel *labyxz;

    QLineEdit *txtMinBc;
    QLineEdit *txtMinJc;
    QLineEdit *txtMaxBc;
    QLineEdit *txtMaxJc;
    QLineEdit *txtAvgBc;
    QLineEdit *txtAvgJc;

    QLabel *labSync;
    QLabel *labSyncPng;
    QTableView *tabTd;
    QRadioButton *rdoCltd;
    QRadioButton *rdoAlltd;
//    QTextEdit *txtXX;
    QTabWidget *tabwc;
    QWidget *widgetWc;
    QWidget *widgetWcTxt;
    QWidget *widgetWcData;
    QWidget *widgetChnlMapping;
    QWidget *widgetAdd;
    QComboBox *cboTbfs;
    QComboBox *cboBzSelect;
    QComboBox *cboBcSelect;
    QComboBox *cboBctd;
    QPushButton *btnChannelMapping;
    QComboBox *cboCTPT;
    QComboBox *cboJD;
    QComboBox *cboBhCl;
    QLineEdit *txtEdyc;
    QComboBox *cboEdycDw;
    QLineEdit *txtBzXdy;
    QLineEdit *txtBcXdy;
    QComboBox *cboCyfs;
    QLineEdit *txtMac;
    QLineEdit *txtTestNum;
    QComboBox *cboInput;
    QComboBox *cboSave;

    QPushButton *btnGet;
    QLabel *labBctd;
    QLabel *labBhCl;
    QLabel *labBzXdy;
    QLabel *labBcXdy;
    QLabel *labCyfs;
    QLabel *labMac;
    QWidget *widgetWcShow;

    QPushButton *btnAnalyzeHarmonic;
    QPushButton *btnAll;
    QPushButton *btnTest;//开始按钮
    QPushButton *btnSource;//功率源的升源按钮
    QPushButton *btnSave;

    QTableView *tabWcData;
    QLineEdit *txtXuhao;
    QLineEdit *txtTbfs;
    QLineEdit *txtBzxz;
    QLineEdit *txtBcxz;
    QLineEdit *txtYc;
    QLineEdit *txtDate;
    QPushButton *btnFirst;
    QPushButton *btnPrevious;
    QPushButton *btnNext;
    QPushButton *btnLast;
    QPushButton *btnDel;
    QPushButton *btnFind;
    QStandardItemModel *model;
    QLabel *labYc;
    QLabel *labYcDw;
    QLabel *labDataCount;
    QLabel *labInput;
    QLabel *labTbfs;

    QLabel *labMuDelay;
    QLineEdit *txtMuDelay;
    QLabel *labMuDelayUnit;

    QRadioButton *selectUnSync;
    QRadioButton *selectSync;

    QComboBox *cboSourceVoltageFrom;
    QComboBox *cboSourceCurrentFrom;
    char digi_tdlb[6];
    bool digi_tdlb_show[6];
    QLineEdit *txtSourceVoltage;
    QLineEdit *txtSourceCurrent;
    QComboBox *cboSourceVoltageUnit;

    void changeSty(int);
    ETC_Send *etc_send;
    MUT_Send *mut_send;
    int itype;
    int itype1;
    int itime;
    int iNetPort;

    QComboBox *cboChannelUa ;
    QComboBox *cboChannelUb ;
    QComboBox *cboChannelUc ;
    QComboBox *cboChannelIa ;
    QComboBox *cboChannelIb ;
    QComboBox *cboChannelIc ;

    QLabel *labPhaseAURms;
    QLabel *labPhaseAIRms;

    QLabel *labPhaseBURms;
    QLabel *labPhaseBIRms;

    QLabel *labPhaseCURms;
    QLabel *labPhaseCIRms;

    QLabel *labAUPhaseReal;
    QLabel *labBUPhaseReal;
    QLabel *labCUPhaseReal;

    QLabel *labAIPhaseReal;
    QLabel *labBIPhaseReal;
    QLabel *labCIPhaseReal;

    QLabel *labPhaseAUTest;
    QLabel *labPhaseAITest;

    QLabel *labPhaseBUTest;
    QLabel *labPhaseBITest;

    QLabel *labPhaseCUTest;
    QLabel *labPhaseCITest;

    QLabel *labAUPhaseTest;
    QLabel *labBUPhaseTest;
    QLabel *labCUPhaseTest;

    QLabel *labAIPhaseTest;
    QLabel *labBIPhaseTest;
    QLabel *labCIPhaseTest;

    QLabel *labPhaseAUDelay;
    QLabel *labPhaseBUDelay;
    QLabel *labPhaseCUDelay;

    QLabel *labPhaseAIDelay;
    QLabel *labPhaseBIDelay;
    QLabel *labPhaseCIDelay;

    // real value of the standard
    QLabel *labPhaseAUReal;
    QLabel *labPhaseAIReal;

    QLabel *labPhaseBUReal;
    QLabel *labPhaseBIReal;

    QLabel *labPhaseCUReal;
    QLabel *labPhaseCIReal;

    QLabel *labPhaseAUError;
    QLabel *labPhaseBUError;
    QLabel *labPhaseCUError;

    QLabel *labPhaseAIError;
    QLabel *labPhaseBIError;
    QLabel *labPhaseCIError;

    bool    isUnSync;

    QLabel *labRecordIndex;
    QLabel *labRecordSyncMethod;
    QLabel *labRecordDut;
    QLabel *labRecordStdValue;
    QLabel *labRecordStdInput;
    QLabel *labRecordDate;

private:
    void inittabTd();
    void inittabWcData();

    QRadioButton *labPhaseAU;
    QRadioButton *labPhaseAI;

    QRadioButton *labPhaseBU;
    QRadioButton *labPhaseBI;

    QRadioButton *labPhaseCU;
    QRadioButton *labPhaseCI;

public slots:
    void slotList();
    void slotScl();

    void bcselect();
    void changeCyfs();
    void showChannelMapping();
    void updateChannelMapping();
    void changeShowChannel();
    void changeTbfs();
signals:
    void sigList();
    void sigScl();
};

class LuboPage : public QWidget
{
    Q_OBJECT

public:
    LuboPage(QWidget *parent = 0);
public:
    QWidget *paintArea;

    QComboBox *combLuboTime;
    QLabel *labBt;
    QTextEdit *txtLubo;
 //   QPushButton *btnLubo;
 //   QWidget *widget;
    QLineEdit *txtLuboTime;

    ClickableLabel *labColor1;
    ClickableLabel *labColor2;
    ClickableLabel *labColor3;
    ClickableLabel *labColor4;
    ClickableLabel *labColor5;
    ClickableLabel *labColor6;
    ClickableLabel *labColor7;
    ClickableLabel *labColor8;
    ClickableLabel *labColor9;
    ClickableLabel *labColor10;
    ClickableLabel *labColor11;
    ClickableLabel *labColor12;
    QRadioButton *rdoAll;
    QRadioButton *rdoOne;
    QCheckBox *chkSelectAll;
    QScrollBar *scrllCurve;
    QSlider *tSlider;
    QLabel *lblY_1;
    QLabel *lblY_2;
    QLabel *lblY_3;
    QLabel *lblY_4;
    QLabel *lblY_5;
    QLabel *lblY_6;
    QLabel *lblY_7;
    QLabel *lblY_8;
    QLabel *lblY_9;
    QLabel *lblY_10;
    QLabel *lblY_11;
    QLabel *lblY_12;
    QLabel *lblY_13;
    QLabel *lblY_14;
    QLabel *lblY_15;
    QLabel *lblY_16;

    QLabel *lblYY[16];
    QPushButton *btnLuboData;

    QPushButton *btnStart;

public slots:
    void slotCheckedAll();
};


class SysPage : public QWidget
{
    Q_OBJECT

public:
    SysPage(QWidget *parent = 0);
public:
    QTabWidget *tabWidget;
  //  QPushButton *btnSysOk;
  //  QPushButton *btnSysCancel;
    QLabel *labGuiyuecanshu;
  //  QSpinBox *spiBCCYSL;
    QLineEdit *txtBCCYSL;

    QLabel *labMima;
    QLineEdit *txtMima;
    QPushButton *btnEnter;
    QWidget *widgetMima;
  //  QGroupBox *boxBc;
  //  QGroupBox *boxInfo;
  //  QGroupBox *boxSetup;
    QWidget *widgetBc;
    QWidget *widgetInfo;
    QLabel *labBcbc;
    QLabel *labJcbc;
    QLineEdit *txtBcbc;
    QLineEdit *txtJcbc;    
    QComboBox *cboDatatime;
    QPushButton *btnSystoUpdate;
    QLineEdit *txtSysXs;
    QLineEdit *txtSysBc;
    QLineEdit *txtSysJc;
    QComboBox *cboSysSf;
    bool BLDG;

    QTableView *tabMU;
    QTableView *tabList;
    QStandardItemModel *model1;
    QStandardItemModel *model2;
  //  QPushButton *btnReturn;
  //  QPushButton *btnSelect;
    QTabWidget *tabSys;
    QTableView *tabCsbc;
    QStandardItemModel *model;
    QPushButton *btnBc;

    QWidget *widgetSysbc;
    QWidget *widgetSetup;
    QComboBox *cboBzbc;
    QLineEdit *txtbc;
    QLineEdit *txtbc1;
    QLineEdit *txtbc2;
    QLineEdit *txtbc3;
    QLineEdit *txtjc;
    QLineEdit *txtjc1;
    QLineEdit *txtjc2;
    QLineEdit *txtjc3;
    QPushButton *btnSysSave;
    QLabel *labCcbh;
    QLabel *labHardware;
    QLabel *labSoftware;

public slots:
    void mimaCheck();
};

class WcPage : public QWidget
{
    Q_OBJECT

public:
    WcPage(QWidget *parent = 0);
public:
    QTableView *tabWc;    
    QLineEdit *txtXuhao;
    QLineEdit *txtTbfs;
    QLineEdit *txtBzxz;
    QLineEdit *txtBcxz;
    QLineEdit *txtYc;
    QLineEdit *txtDate;
    QPushButton *btnFirst;
    QPushButton *btnPrevious;
    QPushButton *btnNext;
    QPushButton *btnLast;
    QPushButton *btnDel;
    QPushButton *btnFind;
    QStandardItemModel *model;
    QLabel *labYc;
    QLabel *labYcDw;
    QLabel *labDataCount;

private:
    void inittabWc();
};

class AddPage : public QWidget
{
    Q_OBJECT

public:
    AddPage(QWidget *parent = 0);
    typedef struct _ETC_Mn
    {
        unsigned int    xbNum;  //谐波次数
     //   float	xdy;    /*谐波小电压*/
        float yxz;  //谐波有效值
    }ETC_Mn;
    typedef struct _ETC_Ft3
    {
        char    lx;  //类型  0:ft3; 1:扩展ft3
        char	cypl;    //采样频率 0: 4K; 1: 12.8K
        char btl;  //波特率 0:2.5; 1:5; 2:10
        char LNName;
        char LDName[2];
        char DSName;
        char tdNum;
        unsigned short EDdl;
        unsigned short EDzxdl;
        unsigned short EDdy;
        unsigned short EDys;
        char status1[2];
        char status2[2];
        unsigned short fz[24];
        unsigned short fzdw[24];
        unsigned short xj[24];

    }ETC_Ft3;
    typedef struct _ETC_Add
    {
        char    de_name[6];
        char	sf;    /*功能选择  a：模拟加量，b：FT3加量 */
        char wl;
        ETC_Mn etc_mn;
        ETC_Ft3 etc_ft3;
    }ETC_Add;
public:
    QTabWidget *twCC;
    QLabel *labInfo;
    QRadioButton *rdoMn;
    QRadioButton *rdoFt3;

    QTableView *tabMn;
    QTableView *tabInfo;
    QTableView *tabControl;
    QTableView *tabChannel;

    QWidget *pageAnalog;
    QLineEdit *txtUn;
    QLineEdit *txtPercent;
    QCheckBox *ckboxHarmonic;
    QTableView *tabHarmonic;
    QByteArray cmdToDA;

private:
    void inittabAdd();
public:
    void inittabTdinfo(int);
    bool analogCmd();
public slots:
    void showMnOrFt3();
    void quickPercent(int btnId);
public:
    ETC_Add *etc_add;
    void getsendUdpAdd(char* ch,int flag);
    int getStructAddLen();
};

class BwjyPage : public QWidget
{
    Q_OBJECT

public:
    BwjyPage(QWidget *parent = 0);
public:
    QTabWidget *tabWidget;
  //  QPushButton *btnBwStart;
 //   QPushButton *btnBwStop;
    QGroupBox *boxWZX;
  //  QGroupBox *boxLSD;
    QGroupBox *boxXB;
  //  QGroupBox *boxMU;
    QWidget *widgetMU;
    QWidget *widgetWZX;
    QWidget *widgetXB;
    QWidget *widgetSZB;

    QWidget *paintArea;
    QPushButton *btnStart;

    QLabel *labDzl;
    QLineEdit *txtDzl;
    QLabel *labLsd;
    QLineEdit *txtLsd;
    QTableView *tabTd;
    QStandardItemModel *modelTd;
    QComboBox *cboXieboNum;
    QComboBox *cboTdh;
    QLineEdit *txtXbHyl;

    QLabel *txterror1;
    QLabel *txterror2;
    QLabel *txterror3;
    QLabel *txterror4;

    QLineEdit *txtYs;
    QLineEdit *txtMaxYs;
    QLineEdit *txtMinYs;
    QLineEdit *txtAvgYs;
    QLineEdit *txtMaxJg;
    QLineEdit *txtMinJg;
    QLineEdit *txtBwAll;
    QLineEdit *txtBwLost;
    QLineEdit *txtBwError;
    QTabWidget *twCC;
    QWidget *widgetDS;
    QLabel *txtDs;
    QLabel *txtMaxDs;
    QLabel *txtSs;
    QLabel *txtMaxSs;
    QLineEdit *txtDsTime;
    QLineEdit *txtSsTime;
    QComboBox *cboBcsz;
    QComboBox *cboTime;
    QComboBox *cboInput;
    QLabel *labInfo;
    QLabel *labInfoDs;

    QComboBox *cboBzsz;

    QRadioButton *beginDsTesting;
    QRadioButton *beginSsTesting;
    QComboBox *combTestingTime;
    QLabel *labCurrentJDYS;
    QLabel *labCurrentJDYS_avg;
    QLabel *labJDYS_avg;

    QLabel *labResutUA;
    QLabel *labResutUB;
    QLabel *labResutUC;
    QLabel *labResutIA;
    QLabel *labResutIB;
    QLabel *labResutIC;

    QLineEdit *showResultUA;
    QLineEdit *showResultUB;
    QLineEdit *showResultUC;
    QLineEdit *showResultIA;
    QLineEdit *showResultIB;
    QLineEdit *showResultIC;

    QCheckBox *enableUA;
    QCheckBox *enableUB;
    QCheckBox *enableUC;
    QCheckBox *enableIA;
    QCheckBox *enableIB;
    QCheckBox *enableIC;

private:
    void inittabTd();
//    void inittabAdd();
public:
    void xiebonum(int);
 //   void inittabTdinfo(int);

public slots:
    void dsTestingIsChecked();
    void changeSync(int index);

private:
    QLabel *labDs;
    QLabel *labMaxDs;
    QLabel *labSs;
    QLabel *labMaxSs;
};

class AllPage : public QWidget
{
    Q_OBJECT

public:
    AllPage(QWidget *parent = 0);

public:
    QWidget *widget[12];
    QLabel *labTd[12];
    QPushButton *btnNext;
    QPushButton *btnPre;
public:
    void setTDH(int);
};
class SclPage : public QWidget
{
    Q_OBJECT

public:
    SclPage(QWidget *parent = 0);

public:
    QTableView *tabScl;
    QTableView *tabSclInfo;
    QPushButton *btnOK;
    QLabel *labTdh;
    QComboBox *cboTdh;

    QLabel *labInfo;
};
class betaTestingPage : public QWidget
{
    Q_OBJECT

public:
    betaTestingPage(QWidget *parent = 0);

};

#endif
